from functools import wraps
import time

def timing_decorator(func):
    @wraps(func)  # 保留原函数元信息
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print(f"{func.__name__} 执行时间: {end - start:.4f}秒")
        return result
    return wrapper

@timing_decorator
def calculate_sum(n):
    """计算1到n的和"""
    return sum(range(1, n + 1))

print(calculate_sum.__name__)  # 输出: calculate_sum
print(calculate_sum.__doc__)   # 输出: 计算1到n的和
print(calculate_sum(1000000))